#!/bin/sh
# author:gaoxu
# description:tiktokdownloader auto pload

readonly path="/Users/gaoxu/Downloads/douyin"

echo '启动抖音自动化上传'
# 进入脚本目录
cd /Users/gaoxu/personal_workspace/social-auto-upload
# 启动虚拟机环境
source ./venv/bin/activate

# 选择操作模式
read -p '请选择上传模式: 1-单账号,多个视频, 2-指定账号,指定视频: ' mode

if [ "$mode" = "1" ]; then
    read -p "请输入你要发布的账号用户名:" username
    python cli_main.py douyin $username login
    # 遍历当前目录下文件名称
    files=$(ls $path)
    for filename in $files;do
        # 判断文件名后缀
        if [[ $filename == *.mp4 ]]; then
            python cli_main.py douyin $username upload "$path/$filename" -pt 0
            echo "文件名 $filename 抖音发布成功!"
        fi
    done
elif [ "$mode" = "2" ]; then
    continue_loop="yes"
    while [ "$continue_loop" = "yes" ]; do
        # 上传抖音视频
        read -p "请输入你要发布的账号用户名:" username
        python cli_main.py douyin $username login
        echo '用户登录成功!'
        read -p "请输入你要发布的作品名称:" fileName
        python cli_main.py douyin $username upload "/Users/gaoxu/Downloads/douyin/$fileName.mp4" -pt 0
        # 在每次循环迭代时，询问用户是否要继续
        echo "Do you want to continue? (yes/no)"
        read continue_loop
    done
else
    echo "参数有误!,无此模式!"
fi
echo '抖音视频发布成功'



